| Visual Basic (Declaration) | |
|---|---|
Public Overloads Overrides Function Read( _ ByVal buffer() As Byte, _ ByVal offset As Integer, _ ByVal size As Integer _ ) As Integer | |
| Visual Basic (Usage) | Copy Code |
|---|---|
Dim instance As TcpStream Dim buffer() As Byte Dim offset As Integer Dim size As Integer Dim value As Integer value = instance.Read(buffer, offset, size) | |
Parameters
- buffer
- The storage location for the received data.
- offset
- The zero-based position in the buffer at which to store the received data.
- size
- The maximum number of bytes to read.
Return Value
The total number of bytes read into the buffer.| Exception | Description |
|---|---|
| System.IO.IOException | Thrown when the stream is not Readable. |
| System.ArgumentNullException.#ctor | Thrown when the receiving buffer is null. |
| System.ArgumentOutOfRangeException.#ctor | Thrown when the offset is less than zero or when size is less than or equal to zero. |
| System.ArgumentException.#ctor | Thrown when the (offset + size) > buffer.Length. |
This is the standard method to use when reading a stream synchronously.
The return value may be less than the number of bytes requested if that many bytes are not currently available, or zero if the end of the stream has been reached. Applications must check this value to know how many bytes were read into the buffer.
Target Platforms: Microsoft .NET Framework 2.0